Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-deceiver

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-deceiver

Deceive HTTP parser

  • 1.2.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12M
increased by6.12%
Maintainers
1
Weekly downloads
 
Created

What is http-deceiver?

The http-deceiver npm package is designed to manipulate HTTP requests and responses. It allows developers to intercept, modify, and create custom behaviors for HTTP traffic, which is particularly useful in testing and development environments where simulating various network conditions and responses is necessary.

What are http-deceiver's main functionalities?

Intercept and modify HTTP requests

This feature allows you to intercept HTTP requests and modify properties such as the URL before the server processes them. In the provided code, the request URL is changed to '/modified-path', and a custom response is sent back.

const httpDeceiver = require('http-deceiver');
const http = require('http');

const server = http.createServer((req, res) => {
  httpDeceiver.deceive(req, res, (req, res) => {
    req.url = '/modified-path';
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Request was modified');
  });
});

server.listen(3000);

Simulate server responses

This feature is useful for simulating different server responses under various conditions. In this example, a 503 Service Unavailable response is simulated regardless of the actual server state or the incoming request.

const httpDeceiver = require('http-deceiver');
const http = require('http');

const server = http.createServer((req, res) => {
  httpDeceiver.deceive(req, res, (req, res) => {
    res.writeHead(503, {'Content-Type': 'text/plain'});
    res.end('Service Unavailable');
  });
});

server.listen(3000);

Other packages similar to http-deceiver

Keywords

FAQs

Package last updated on 17 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc